package com.diaohw.platform.remote.log;

import com.diaohw.platform.common.LogProcessAPI;
import com.diaohw.platform.common.obj.log.DbLog;
import com.diaohw.platform.common.obj.log.RequestLog;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class HttpLogProcess implements LogProcessAPI {

    private static final ExecutorService executor = Executors.newCachedThreadPool();
    @Resource
    LogRemoteService logRemoteService;

    @Override
    public void http(RequestLog requestLog) {
        executor.execute(() -> logRemoteService.insert(requestLog));
    }

    @Override
    public void db(DbLog dbLog) {
        executor.execute(() -> logRemoteService.insert(dbLog));
    }

}
